#ifndef _ROOM_MANAGER_H_
#define _ROOM_MANAGER_H_

#include "Define.h"
#include "LogEx.h"
#include "StackTrace.h"
#include <set>
#include <deque>

class CRoomManager
{
    SINGLETON_CLASS_DEFINE(CRoomManager);

public:
    enum
    {
        E_Room_Free,
        E_Room_InUse,
    };

    bool Init(s32 count);
    void Fini();
    
    s32 GetRoom();
    s32 GetRoom(s32 id);
    void PutRoom(s32 id);
    bool RoomInUse(s32 id);
    const std::set<s32>& GetUsingList();
    void AddHalfFullRoom(s32 id);
    void RemoveHalfFullRoom(s32 id);
    const std::set<s32>& GetHalfFullList();
    s32 GetFreeCount() { return m_freeList.size(); }
    s32 GetUsingCount() { return m_usingList.size(); }
    s32 GetHalfFullCount() { return m_halfFullList.size(); }
    s32 GetTotalCount() { return m_count; }

private:
    void _SetRoomFlag(s32 id, s8 flag);

private:
    s32 m_count;
    s8 *m_flag;
    std::set<s32> m_freeList;
    std::set<s32> m_usingList;
    std::set<s32> m_halfFullList;
};

#endif

